package com.ponhu.ea2.vo;

import com.ponhu.ea2.enums.InventoryAppraisalEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Optional;

@Data
@Accessors(chain = true)
@ApiModel(value = "货品列表查询-数据传输模型 ")
public class PhInventoryListVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "货品ID")
    private Long id;

    @ApiModelProperty(value = "货品ID字符串")
    private String idStr;

    @ApiModelProperty(value = "货品编码")
    private String inventoryCode;

    @ApiModelProperty(value = "物料编码")
    private String materialCode;

    @ApiModelProperty(value = "货品名称")
    private String inventoryName;

    @ApiModelProperty(value = "货品主图")
    private String mainImage;

    @ApiModelProperty(value = "品牌名称")
    private String brandName;

    @ApiModelProperty(value = "品类名称")
    private String categoryName;

    @ApiModelProperty(value = "系列名称")
    private String seriesName;

    @ApiModelProperty(value = "系列别名")
    private String seriesOtherName;

    @ApiModelProperty(value = "型号名称")
    private String modelName;

    @ApiModelProperty(value = "来源渠道")
    private String sourceChannel;

    @ApiModelProperty(value = "货品类型：0-全部，1-主品，2-附件，3-配件，4-赠品")
    private Integer inventoryType;

    @ApiModelProperty(value = "是否二奢：0-全部，1是，2否")
    private Integer isSecondhand;

    @ApiModelProperty(value = "成色值")
    private String qualityValue;

    @ApiModelProperty(value = "货品来源渠道：字典值")
    private Integer inventoryChannel;

    @ApiModelProperty(value = "货品来源渠道：字典标签名称")
    private String ivtChannelLabel;

    @ApiModelProperty(value = "中检状态：0-全部，1未中检，2中检已通过，3中检未通过，4中检无结果, 5不符合挂签标准")
    private Integer isDoneCcic;

    @ApiModelProperty(value = "中检状态说明")
    private String isDoneCcicStr;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createdTime;

    @ApiModelProperty(value = "备注")
    private String remarks;

    public String getInventoryType() {
        return "主品";
    }

    public String getIsDoneCcicStr() {
        Optional<String> optional = Arrays.stream(InventoryAppraisalEnum.values())
                .filter(aEnum -> aEnum.getCode().equals(isDoneCcic))
                .map(InventoryAppraisalEnum::getName).findFirst();
        if (optional.isPresent()) return optional.get();
        else return null;
    }

}
